<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<% 
	String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+request.getContextPath()+"/";
	pageContext.setAttribute("basePath",basePath);
%> 
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
		<meta http-equiv="Content-Security-Policy" content="upgrade-insecure-requests">
		<title>公告列表</title>
		<link rel="icon" href="<%=basePath %>views/gj/img/favicon.png" type="image/x-icon">
		<link rel="stylesheet" href="<%=basePath %>views/lcx/layui-v2.5.5/layui/css/layui.css" />
		<link rel="stylesheet" href="<%=basePath %>views/lcx/layui-v2.5.5/layui/css/modules/layer/default/layer.css" />
		<link rel="stylesheet" href="<%=basePath %>views/lcx/css/listManager.css" />
		<script src="<%=basePath %>views/lcx/layui-v2.5.5/layui/layui.js"></script>
		<script src="<%=basePath %>views/lcx/layui-v2.5.5/layui/lay/modules/layer.js"></script>
		<script type="text/javascript" src="<%=basePath %>views/lcx/js/jquery-3.3.1.min.js" ></script>
	</head>
	<body>
		<div class="my_right">
			<div class="box_right">所有公告</div>
			<c:choose>
				<c:when test="${size==0}">
					<div>
						<img style="width: 775px" src="${basePath }views/lcx/img/12.jpg">
					</div>
				</c:when>
				<c:otherwise>
					<div style="text-align: left; margin: 0px 30px;">
						<c:forEach items="${pageInfo.list}" var="c">
							<div style="padding: 10px 0px;">
								<a style="font-size: 16px; font-family: '宋体'; " href="${c.url }">
									<span style="font-size: 14px; font-family: '宋体'; color: #777777;">
										<fmt:formatDate value="${c.create_time}" type="date" pattern="yyyy-MM-dd HH:mm"/>
									</span>
									${c.title }
								</a>
								<a onclick="delNotice('${c.sysid}')" style="font-size: 14px; font-family: '宋体';  color: #777777; margin-left: 20px; cursor: pointer;">删除</a>
							</div>
						</c:forEach>
						<div class="row">
							<div class="dataTables_info">
								第 ${(pageInfo.pageNum-1)*pageInfo.pageSize+1} 到 ${pageInfo.pageNum*pageInfo.pageSize} 条记录，共${pageInfo.total }条
							</div>
							<ul class="pagination" >
								<li>
									 <c:if test="${pageInfo.hasPreviousPage }">
									 	<a href="${basePath }noticeManagerInit?pageNo=${pageInfo.pageNum-1}">上一页</a>
									 </c:if>
								</li>
								<li class="avtive">
									<a href="#">第${pageInfo.pageNum}页</a>
								</li>
								<li>
									<c:if test="${pageInfo.hasNextPage }">
										<a href="${basePath }noticeManagerInit?pageNo=${pageInfo.pageNum+1}">下一页</a>
									</c:if>
								</li>
							</ul>
						</div>
					</div>
				</c:otherwise>
			</c:choose>
		</div>
		
		<script type="text/javascript">
			function delNotice(data){
				$.ajax({ //
					type : "get",
					url : "${basePath}delnoticebyid", //添加操作的路径
					data : {sysId:data},//添加用户的基本信息
					dataType : "JSON", //返回JSON格式的数据
					async : false,//同步传输
					success : function(data) {
						if(data==1){
							alert("删除成功！！");
						}else{
							alert("删除失败！！");
						}
					}
				});
				location.reload();//重新刷新页面
			}
		
		</script>
	</body>
</html>